package com.xbh.boot_study.interceptor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @MyHandlerInterceptor:
 * @author: ZBoHang
 * @time: 2021/9/23 8:55
 */
@Component
public class MyInterceptor implements HandlerInterceptor {

    private static final Logger S_LOG = LoggerFactory.getLogger(MyInterceptor.class);

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        S_LOG.info("@@@@@@@@@@@@@@@ ----->>>>> pre");
        return HandlerInterceptor.super.preHandle(request, response, handler);
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        S_LOG.info("@@@@@@@@@@@@@@@ ----->>>>> after");
        HandlerInterceptor.super.afterCompletion(request, response, handler, ex);
    }
}
